<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 15-1-8
 * Time: 下午6:00
 */
namespace Admin\Controller;
use Mcit\Page;
//站点管理
class CompController extends BaseController {
    //首页
    public function index(){

        if(!empty($_GET['name'])){
           // echo I('get.name');
            $map['content'] = array('like','%'.I('get.name').'%');
        }
         $count=D("Comp")->where($map)->relation(true)->count();
//        $model = new Model();
//        $count=$model->query("select * from ev_complain as a,ev_member as b where a.memberID=b.id and b.nickname=".I('get.name'));

        //分页
        vendor('Mcit.Sys.Page');
        $Page = new Page($count, 20);
        $pageView = $Page->show();
        $this->assign('pageView', $pageView); //发送分页
        $nowPage = isset($_GET['page']) ? $_GET['page'] : 1;
        $rs = D("Comp")->where($map)->order("id desc")->relation(true)->page($nowPage . ',' . $Page->listRows)->select();
        //分页结束


        $this->assign("rs",$rs);
        $this->display();
    }
 
 	//查看详细
	public function detail(){
        $id=$_GET["id"];
        $rs=D("Comp")->where("id=".$id)->relation(true)->select();
        //P($rs);
        $this->assign("rs",$rs);
			$this->display();
		}
    public  function  del(){


        $rs=M("complain")->where("id=".$_POST["id"])->delete();

        if($rs){
            echo "1";
        }else{
            echo "0";
        }
    }
}
